<?php
class SP_Config_Configuration
{
	public function __construct($path=null)
	{
		if( $path )$this->read($path);
	}
	
	private $SP_CONFIG_ARRAY=array();
	
	function __set($name,$value)
	{
		$this->SP_CONFIG_ARRAY[$name]=$value;
	}
	
	function __get($name)
	{
		return $this->SP_CONFIG_ARRAY[$name];
	}
	
	public function has($name)
	{
		return array_key_exists($name, $this->SP_CONFIG_ARRAY);
	}
	
	public function set($name,$value)
	{
		$this->SP_CONFIG_ARRAY[$name]=$value;
	}
	
	public function get($name,$value=NULL)
	{
		return $this->has($name)? $this->SP_CONFIG_ARRAY[$name] : $value;
	}
	
	public function getAll()
	{
		return $this->SP_CONFIG_ARRAY;
	}
	
	public function clear()
	{
		$this->SP_CONFIG_ARRAY = array();
	}
	
	public function read($path)
	{
		if (file_exists($path) && is_readable($path))
		{
			$this->clear();
			include($path);
			return true;
		}
		else
		{
			return false;
		}
	}
}
?>